package com.twxm.breed.service;

import com.twxm.breed.entity.Department;
import com.twxm.breed.mapper.DepartmentMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    public List<Department> getAllDepartments() {
        return departmentMapper.selectAll();
    }

    public Department getDepartmentById(int id) {
        return departmentMapper.selectById(id);
    }

    public int addDepartment(Department department) {
        return departmentMapper.insert(department);
    }

    public int updateDepartment(Department department) {
        return departmentMapper.updateById(department);
    }

    public int deleteDepartmentById(int id) {
        return departmentMapper.deleteById(id);
    }
}

